# -*- coding: utf-8 -*-

import unittest
from Crawler import UfrgsCrawler

class TestUfrgsCrawler(unittest.TestCase):
    def setUp(self):
        self.crawler = UfrgsCrawler()
        self.course_name = u'ciência da computação'
        
    def test_initialization(self):
        self.assert_(self.crawler.CHARSET)
        self.assert_(self.crawler.COURSES_URL)
        self.assert_(self.crawler.QUALIFICATIONS_URL)
        
    def test_getCourseCode(self):
        self.assertTrue(isinstance(
                self.crawler.getCourseCode(self.course_name), unicode))
        
    def test_getQualificationCode(self):
        course_code = self.crawler.getCourseCode(self.course_name)
        self.assertTrue(isinstance(
                self.crawler.getQualificationCode(course_code), unicode))
        
    def test_getCurriculumCode(self):
        course_code = self.crawler.getCourseCode(self.course_name)
        qualification_code = self.crawler.getQualificationCode(course_code)
        self.assertTrue(isinstance(
                self.crawler.getCurriculumCode(course_code, qualification_code),
                unicode))
        
    def test_getDocketDict(self):
        course_code = self.crawler.getCourseCode(self.course_name)
        qualification_code = self.crawler.getQualificationCode(course_code)
        curriculum_code = self.crawler.getCurriculumCode(course_code, 
                                                         qualification_code)
        docketDict = self.crawler.getDocketDict(course_code,
                                                qualification_code,
                                                curriculum_code)
        self.assertTrue(isinstance(docketDict, dict))
                
    